package Controllers;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import GUI.AddLivArTabGUI;
import GUI.MainWindowGUI;
import GUI.ManageLivArTabGUI;

/**
 * The Class ManageLivArTabController.
 * Controller for living area management.
 */
public class ManageLivArTabController {
	/** The main window. */
	public static MainWindowGUI mainWindow;
	
	/** The manage living area table gui. */
	private ManageLivArTabGUI manageLivArTabGUI;
	/** The previous controller. */
	private MarketingManagerController prev;

	/**
	 * Instantiates a new manage living area table controller.
	 *
	 * @param manageLivArTabGUI the manage living area table gui
	 */
	public ManageLivArTabController(ManageLivArTabGUI manageLivArTabGUI) {
		this.manageLivArTabGUI = manageLivArTabGUI;
		this.manageLivArTabGUI.addAddActionListener(new AddListener());
		this.manageLivArTabGUI.addBackActionListener(new BackListener());

	}

	
	/**
	 * The listener interface for receiving add events.
	 * The class that is interested in processing a add
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addAddListener<code> method. When
	 * the add event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see AddEvent
	 */
	class AddListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent e) {
			AddLivArTabGUI addLivArTabGUI = new AddLivArTabGUI();
			new AddLivArTabController(addLivArTabGUI).setPrev(ManageLivArTabController.this);
			LoginController.mainWindow.setContentPane(addLivArTabGUI);
			
		}
		
	}
	
	
	
	
	/**
	 * The listener interface for receiving back events.
	 * The class that is interested in processing a back
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addBackListener<code> method. When
	 * the back event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see BackEvent
	 */
	
	class BackListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent arg0) {
			LoginController.mainWindow.setContentPane(prev.getMarketingManagerGui());
			LoginController.mainWindow.setTitle("Marketing manager");
		}
	
	}
	
	/**
	 * Sets the previous controller.
	 *
	 * @param prev the new previous controller
	 */
	public void setPrev(MarketingManagerController prev) {
		this.prev=prev;
		
	}
	
	/**
	 * Gets the manage living area table gui.
	 *
	 * @return the Manage living area table gui
	 */
	public ManageLivArTabGUI getManageLivArTabGUI() {
		return manageLivArTabGUI;
	}


}


